import { createSlice } from '@reduxjs/toolkit'
import dayjs from 'dayjs'
export const cityle = createSlice({
  name: 'cityle',
  initialState: {
    start: '北京',
    end: '广州',
    date: dayjs().format('YYYY-MM-DD')

  },
  reducers: {

    deitchange(state, { payload: { type, city } }) {
      state[type] = city
    }
    ,
    //  互换
    changecity(state) {
      const ct = state.start
      state.start = state.end
      state.end = ct
    },
    day(state, { payload }) {
      state.date = payload.date
    }

  }
})
// 每个 case reducer 函数会生成对应的 Action creators
export const { deitchange, changecity, day } = cityle.actions

export default cityle.reducer